package cian_f_rice.view;

import java.awt.Graphics;

import javax.swing.JPanel;

import cian_f_rice.model.DecisionLinesEvent;
import cian_f_rice.model.Edge;
import cian_f_rice.model.Line;

/**
 * @author Professor Heineman
 *
 */

public class DecisionLinesPanel extends JPanel {

	/** Model. */
	DecisionLinesEvent model;
	
	/**
	 * Create the panel.
	 */
	public DecisionLinesPanel(DecisionLinesEvent m) {
		this.model = m;
	}
		
	/**
	 * Draw the decisionLines board here. 
	 */
	@Override
	public void paintComponent(Graphics g) {
		// be sure to do the "right thing" by swing.
		super.paintComponent(g);
		
		// This draws lines based on width of panel, which is the same width as the choicesPanel
		int width = getWidth()/model.numChoices;
		int choiceWidth = width-20;
		for (int i = 0; i < model.numChoices; i++) {
			// make sure to offset lines horizontally by width/2 for proper centering.
			g.drawLine(i*width + choiceWidth/2, 10, i*width + choiceWidth/2, getHeight());
		}
		
		// Now you could add logic to draw edges
		
		
		for (Line line : model.lines)
		{
			for (Edge edge : line.edges)
			{
				g.drawLine(edge.getLeft() * width + choiceWidth/2, edge.getHeight(), edge.getRight() * width + choiceWidth/2, edge.getHeight());
			}
		}
		
	}
	
	
}
